home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg2.cab / style_mapping_html32.xsl < prev    next >
Extensible Markup Language  |  2005-09-10  |  15KB  |  466 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.     OpenOffice.org - a multi-platform office productivity suite
  5.  
  6.     $RCSfile: style_mapping_html32.xsl,v $
  7.  
  8.     $Revision: 1.5 $
  9.  
  10.     last change: $Author: rt $ $Date: 2005/09/08 22:02:14 $
  11.  
  12.     The Contents of this file are made available subject to
  13.     the terms of GNU Lesser General Public License Version 2.1.
  14.  
  15.  
  16.       GNU Lesser General Public License Version 2.1
  17.       =============================================
  18.       Copyright 2005 by Sun Microsystems, Inc.
  19.       901 San Antonio Road, Palo Alto, CA 94303, USA
  20.  
  21.       This library is free software; you can redistribute it and/or
  22.       modify it under the terms of the GNU Lesser General Public
  23.       License version 2.1, as published by the Free Software Foundation.
  24.  
  25.       This library is distributed in the hope that it will be useful,
  26.       but WITHOUT ANY WARRANTY; without even the implied warranty of
  27.       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  28.       Lesser General Public License for more details.
  29.  
  30.       You should have received a copy of the GNU Lesser General Public
  31.       License along with this library; if not, write to the Free Software
  32.       Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  33.       MA  02111-1307  USA
  34.  
  35. -->
  36. <!--
  37.     For further documentation and updates visit http://xml.openoffice.org/sx2ml
  38. -->
  39. <xsl:stylesheet version="1.0"
  40.                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  41.                 xmlns:office="http://openoffice.org/2000/office"
  42.                 xmlns:style="http://openoffice.org/2000/style"
  43.                 xmlns:text="http://openoffice.org/2000/text"
  44.                 xmlns:table="http://openoffice.org/2000/table"
  45.                 xmlns:draw="http://openoffice.org/2000/drawing"
  46.                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
  47.                 xmlns:xlink="http://www.w3.org/1999/xlink"
  48.                 xmlns:number="http://openoffice.org/2000/datastyle"
  49.                 xmlns:svg="http://www.w3.org/2000/svg"
  50.                 xmlns:chart="http://openoffice.org/2000/chart"
  51.                 xmlns:dr3d="http://openoffice.org/2000/dr3d"
  52.                 xmlns:math="http://www.w3.org/1998/Math/MathML"
  53.                 xmlns:form="http://openoffice.org/2000/form"
  54.                 xmlns:script="http://openoffice.org/2000/script"
  55.                 xmlns:dc="http://purl.org/dc/elements/1.1/"
  56.                 xmlns:meta="http://openoffice.org/2000/meta"
  57.                 xmlns:config="http://openoffice.org/2001/config"
  58.                 xmlns:help="http://openoffice.org/2000/help"
  59.                 exclude-result-prefixes="office style text table draw fo xlink number svg chart dr3d math form script dc meta config help">
  60.  
  61.  
  62.     <xsl:template name="write-style-properties">
  63.         <xsl:param name="style:properties" />
  64.  
  65.         <!--+++++ PALM 3.2 SUBSET AND WAP PROPERTIES  +++++-->
  66.         <xsl:for-each select="$style:properties/@*">
  67.             <xsl:choose>
  68.                 <!--*** FORMAT ATTRIBUTES ***-->
  69.  
  70.                 <!-- Italic -->
  71.                 <xsl:when test='name()="fo:font-style"'>
  72.                     <xsl:if test="contains(., 'italic') or contains(., 'oblique')">
  73.                         <xsl:text>italic, </xsl:text>
  74.                     </xsl:if>
  75.                 </xsl:when>
  76.  
  77.                 <!-- Boldface -->
  78.                 <xsl:when test='name()="fo:font-weight"'>
  79.                     <xsl:if test="contains(., 'bold') or contains(., 'bolder')">
  80.                         <xsl:text>bold, </xsl:text>
  81.                     </xsl:if>
  82.                 </xsl:when>
  83.  
  84.                 <!-- Underline -->
  85.                 <xsl:when test='name()="style:text-underline"'>
  86.                     <xsl:text>underline, </xsl:text>
  87.                 </xsl:when>
  88.  
  89.                 <!-- Alignment -->
  90.                 <xsl:when test='name()="fo:text-align"'>
  91.                      <xsl:choose>
  92.                         <xsl:when test="contains(., 'start')">
  93.                             <xsl:text>align:left, </xsl:text>
  94.                         </xsl:when>
  95.                         <xsl:when test="contains(., 'end')">
  96.                             <xsl:text>align:right, </xsl:text>
  97.                         </xsl:when>
  98.                         <xsl:when test="contains(., 'center')">
  99.                             <xsl:text>align:center, </xsl:text>
  100.                         </xsl:when>
  101.                      </xsl:choose>
  102.                 </xsl:when>
  103.  
  104.                 <!-- strikethrough -->
  105.                 <xsl:when test='name()="style:text-crossing-out"'>
  106.                     <xsl:text>strike, </xsl:text>
  107.                 </xsl:when>
  108.  
  109.                 <!-- Font - size (Palm: emulator transformed sizes to available set (e.g. 30 to (probably) 9)-->
  110.                 <xsl:when test='name()="fo:font-size"'>
  111.                     <xsl:text>size:</xsl:text><xsl:value-of select="." /><xsl:text>:size, </xsl:text>
  112.                 </xsl:when>
  113.  
  114.                 <!-- Font - Color (PALM: but mostly only 2 available)
  115.                     black (#000000)
  116.                     gray (#808080)(rendered as dark gray)
  117.                     silver (#C0C0C0)(rendered as light gray)
  118.                     white (#FFFFFF)-->
  119.                 <xsl:when test='name()="fo:color"'>
  120.                     <xsl:choose>
  121.                         <xsl:when test="contains(. , '#FFFFFF') or contains(. , '#ffffff') or contains(. , 'white') or contains(. , 'WHITE')">
  122.                             <xsl:text>color:#FFFFFF, </xsl:text>
  123.                         </xsl:when>
  124.                         <xsl:otherwise>
  125.                             <xsl:text>color:#000000, </xsl:text>
  126.                         </xsl:otherwise>
  127.                     </xsl:choose>
  128.                 </xsl:when>
  129.  
  130.                 <!--*** TABLE ATTRIBUTES ***-->
  131.                 <xsl:when test='name()="fo:font-size"'>
  132.                     <xsl:text>size:</xsl:text><xsl:value-of select="." /><xsl:text>:size, </xsl:text>
  133.                 </xsl:when>
  134.                 <xsl:when test='name()="style:column-width"'>
  135.                     <xsl:text>width:</xsl:text>
  136.                     <xsl:choose>
  137.                         <!-- changing the distance measure: inch to in -->
  138.                         <xsl:when test="contains(., 'inch')">
  139.                             <xsl:value-of select="substring-before(.,'ch')" />
  140.                         </xsl:when>
  141.                         <xsl:otherwise>
  142.                             <xsl:value-of select="." />
  143.                         </xsl:otherwise>
  144.                     </xsl:choose>
  145.                     <xsl:text>:width, </xsl:text>
  146.                 </xsl:when>
  147.                 <xsl:when test='name()="style:row-height"'>
  148.                     <xsl:text>height:</xsl:text>
  149.                     <xsl:choose>
  150.                         <!-- changing the distance measure: inch to in -->
  151.                         <xsl:when test="contains(., 'inch')">
  152.                             <xsl:value-of select="substring-before(.,'ch')" />
  153.                         </xsl:when>
  154.                         <xsl:otherwise>
  155.                             <xsl:value-of select="." />
  156.                         </xsl:otherwise>
  157.                     </xsl:choose>
  158.                     <xsl:text>:height; </xsl:text>
  159.                 </xsl:when>
  160.                 <xsl:when test='name()="style:width"'> <!--earlier fo:width-->
  161.                     <xsl:text>width:</xsl:text>
  162.                     <xsl:choose>
  163.                         <!-- changing the distance measure: inch to in -->
  164.                         <xsl:when test="contains(., 'inch')">
  165.                             <xsl:value-of select="substring-before(.,'ch')" />
  166.                         </xsl:when>
  167.                         <xsl:otherwise>
  168.                             <xsl:value-of select="." />
  169.                         </xsl:otherwise>
  170.                     </xsl:choose>
  171.                     <xsl:text>:width; </xsl:text>
  172.                 </xsl:when>
  173.             </xsl:choose>
  174.         </xsl:for-each>
  175.     </xsl:template>
  176.  
  177.  
  178.  
  179.     <!-- ********************************* -->
  180.     <!-- *** creating table attributes *** -->
  181.     <!-- ********************************* -->
  182.  
  183.     <!-- table data (td) and table header (th) attributes -->
  184.     <xsl:template name="create-attribute-ALIGN">
  185.         <xsl:param name="styleProperties" />
  186.  
  187.         <xsl:if test="contains($styleProperties, 'align')">
  188.             <xsl:attribute name="align">
  189.                  <xsl:choose>
  190.                     <xsl:when test="contains($styleProperties, 'align:left')">
  191.                         <xsl:text>left</xsl:text>
  192.                     </xsl:when>
  193.                     <xsl:when test="contains($styleProperties, 'align:right')">
  194.                         <xsl:text>right</xsl:text>
  195.                     </xsl:when>
  196.                     <xsl:otherwise>
  197.                         <xsl:text>center</xsl:text>
  198.                     </xsl:otherwise>
  199.                  </xsl:choose>
  200.             </xsl:attribute>
  201.         </xsl:if>
  202.     </xsl:template>
  203.  
  204.  
  205.     <!-- ********************************* -->
  206.     <!-- *** creating List attributes  *** -->
  207.     <!-- ********************************* -->
  208. <!--
  209.     <xsl:template name="create-list-attributes">
  210.         <xsl:param name="styleProperties" />
  211.  
  212.  
  213. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  214. 2 be implemented
  215. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  216.  
  217.  
  218.     </xsl:template>
  219. -->
  220.  
  221.     <!-- ************************************************ -->
  222.     <!-- *** creating nested format tags (PALM & WML) *** -->
  223.     <!-- ************************************************ -->
  224.  
  225.     <!-- Italic -->
  226.     <xsl:template name="create-nested-format-tags">
  227.         <xsl:param name="globalData" />
  228.         <xsl:param name="styleProperties" />
  229.         <xsl:choose>
  230.             <xsl:when test="contains($styleProperties, 'italic')">
  231.                 <xsl:element namespace="{$namespace}" name="i">
  232.                     <xsl:call-template name="bold">
  233.                         <xsl:with-param name="styleProperties" select="$styleProperties" />
  234.                         <xsl:with-param name="globalData" select="$globalData" />
  235.                     </xsl:call-template>
  236.                 </xsl:element>
  237.             </xsl:when>
  238.             <xsl:otherwise>
  239.                 <xsl:call-template name="bold">
  240.                     <xsl:with-param name="styleProperties" select="$styleProperties" />
  241.                     <xsl:with-param name="globalData" select="$globalData" />
  242.                 </xsl:call-template>
  243.             </xsl:otherwise>
  244.         </xsl:choose>
  245.     </xsl:template>
  246.  
  247.  
  248.     <!-- Bold -->
  249.     <xsl:template name="bold">
  250.         <xsl:param name="globalData" />
  251.         <xsl:param name="styleProperties" />
  252.  
  253.         <xsl:choose>
  254.             <xsl:when test="contains($styleProperties, 'bold')">
  255.                 <xsl:element namespace="{$namespace}" name="b">
  256.                     <xsl:call-template name="underline">
  257.                         <xsl:with-param name="styleProperties" select="$styleProperties" />
  258.                         <xsl:with-param name="globalData" select="$globalData" />
  259.                     </xsl:call-template>
  260.                 </xsl:element>
  261.             </xsl:when>
  262.             <xsl:otherwise>
  263.                 <xsl:call-template name="underline">
  264.                     <xsl:with-param name="styleProperties" select="$styleProperties" />
  265.                     <xsl:with-param name="globalData" select="$globalData" />
  266.                 </xsl:call-template>
  267.             </xsl:otherwise>
  268.         </xsl:choose>
  269.     </xsl:template>
  270.  
  271.  
  272.     <!-- Underline : last format attribute, which is also used from WML - WML ends here! -->
  273.     <xsl:template name="underline">
  274.         <xsl:param name="globalData" />
  275.         <xsl:param name="styleProperties" />
  276.  
  277.         <xsl:choose>
  278.             <xsl:when test="$outputType = 'PALM'">
  279.                 <xsl:choose>
  280.                     <xsl:when test="contains($styleProperties, 'underline')">
  281.                         <xsl:element namespace="{$namespace}" name="u">
  282.                             <xsl:call-template name="strikethrough">
  283.                                 <xsl:with-param name="styleProperties" select="$styleProperties" />
  284.                                 <xsl:with-param name="globalData" select="$globalData" />
  285.                             </xsl:call-template>
  286.                         </xsl:element>
  287.                     </xsl:when>
  288.                     <xsl:otherwise>
  289.                         <xsl:call-template name="strikethrough">
  290.                             <xsl:with-param name="styleProperties" select="$styleProperties" />
  291.                             <xsl:with-param name="globalData" select="$globalData" />
  292.                         </xsl:call-template>
  293.                     </xsl:otherwise>
  294.                 </xsl:choose>
  295.             </xsl:when>
  296.             <xsl:otherwise>
  297.                 <xsl:choose>
  298.                     <xsl:when test="contains($styleProperties, 'underline')">
  299.                         <xsl:element namespace="{$namespace}" name="u">
  300.                             <xsl:apply-templates>
  301.                                 <xsl:with-param name="globalData" select="$globalData" />
  302.                             </xsl:apply-templates>
  303.                         </xsl:element>
  304.                     </xsl:when>
  305.                     <xsl:otherwise>
  306.                         <xsl:apply-templates>
  307.                             <xsl:with-param name="globalData" select="$globalData" />
  308.                         </xsl:apply-templates>
  309.                     </xsl:otherwise>
  310.                 </xsl:choose>
  311.             </xsl:otherwise>
  312.         </xsl:choose>
  313.     </xsl:template>
  314.  
  315.  
  316.     <!-- strikethrough -->
  317.     <xsl:template name="strikethrough">
  318.         <xsl:param name="globalData" />
  319.         <xsl:param name="styleProperties" />
  320.  
  321.         <xsl:choose>
  322.             <xsl:when test="contains($styleProperties, 'strike')">
  323.                 <xsl:element namespace="{$namespace}" name="strike">
  324.                     <xsl:call-template name="align">
  325.                         <xsl:with-param name="styleProperties" select="$styleProperties" />
  326.                         <xsl:with-param name="globalData" select="$globalData" />
  327.                     </xsl:call-template>
  328.                 </xsl:element>
  329.             </xsl:when>
  330.             <xsl:otherwise>
  331.                 <xsl:call-template name="align">
  332.                     <xsl:with-param name="styleProperties" select="$styleProperties" />
  333.                     <xsl:with-param name="globalData" select="$globalData" />
  334.                 </xsl:call-template>
  335.             </xsl:otherwise>
  336.         </xsl:choose>
  337.     </xsl:template>
  338.  
  339.  
  340.     <!-- Alignment -->
  341.     <xsl:template name="align">
  342.         <xsl:param name="globalData" />
  343.         <xsl:param name="styleProperties" />
  344.  
  345.         <xsl:choose>
  346.             <xsl:when test="contains($styleProperties, 'align')">
  347.                 <xsl:element namespace="{$namespace}" name="div">
  348.                     <xsl:attribute name="style">
  349.                          <xsl:choose>
  350.                             <xsl:when test="contains($styleProperties, 'align:left')">
  351.                                 <xsl:text>text-align:left;</xsl:text>
  352.                             </xsl:when>
  353.                             <xsl:when test="contains($styleProperties, 'align:right')">
  354.                                 <xsl:text>text-align:right;</xsl:text>
  355.                             </xsl:when>
  356.                             <xsl:otherwise>
  357.                                 <xsl:text>text-align:center;</xsl:text>
  358.                             </xsl:otherwise>
  359.                          </xsl:choose>
  360.                     </xsl:attribute>
  361.                     <xsl:call-template name="font_combined">
  362.                         <xsl:with-param name="styleProperties" select="$styleProperties" />
  363.                         <xsl:with-param name="globalData" select="$globalData" />
  364.                     </xsl:call-template>
  365.                 </xsl:element>
  366.             </xsl:when>
  367.             <xsl:otherwise>
  368.                 <xsl:call-template name="font_combined">
  369.                     <xsl:with-param name="styleProperties" select="$styleProperties" />
  370.                     <xsl:with-param name="globalData" select="$globalData" />
  371.                 </xsl:call-template>
  372.             </xsl:otherwise>
  373.         </xsl:choose>
  374.     </xsl:template>
  375.  
  376.  
  377.     <!-- Both size and Color for font -->
  378.     <xsl:template name="font_combined">
  379.         <xsl:param name="globalData" />
  380.         <xsl:param name="styleProperties" />
  381.  
  382.         <xsl:choose>
  383.             <xsl:when test="contains($styleProperties, 'color') and contains($styleProperties, 'size')">
  384.                 <xsl:element namespace="{$namespace}" name="font">
  385.  
  386.                     <xsl:attribute name="color">
  387.                          <xsl:choose>
  388.                             <xsl:when test="contains($styleProperties, 'color:#000000')">
  389.                                 <xsl:text>#000000</xsl:text>
  390.                             </xsl:when>
  391.                             <xsl:otherwise>
  392.                                 <xsl:text>#FFFFFF</xsl:text>
  393.                             </xsl:otherwise>
  394.                          </xsl:choose>
  395.                     </xsl:attribute>
  396.  
  397.                     <xsl:attribute name="size">
  398.                         <xsl:value-of select="substring-after(substring-before($styleProperties ,':size'), 'size:')" />
  399.                     </xsl:attribute>
  400.  
  401.                     <!-- get the embedded content -->
  402.                     <xsl:apply-templates>
  403.                         <xsl:with-param name="globalData" select="$globalData" />
  404.                     </xsl:apply-templates>
  405.                 </xsl:element>
  406.             </xsl:when>
  407.             <xsl:otherwise>
  408.                 <xsl:call-template name="font_simple">
  409.                     <xsl:with-param name="styleProperties" select="$styleProperties" />
  410.                     <xsl:with-param name="globalData" select="$globalData" />
  411.                 </xsl:call-template>
  412.             </xsl:otherwise>
  413.         </xsl:choose>
  414.     </xsl:template>
  415.  
  416.  
  417.     <!-- size or Color for font -->
  418.     <xsl:template name="font_simple">
  419.         <xsl:param name="globalData" />
  420.         <xsl:param name="styleProperties" />
  421.  
  422.         <xsl:choose>
  423.             <xsl:when test="contains($styleProperties, 'color')">
  424.                 <xsl:element namespace="{$namespace}" name="font">
  425.                     <xsl:attribute name="color">
  426.                          <xsl:choose>
  427.                             <xsl:when test="contains($styleProperties, 'color:#000000')">
  428.                                 <xsl:text>#000000</xsl:text>
  429.                             </xsl:when>
  430.                             <xsl:otherwise>
  431.                                 <xsl:text>#FFFFFF</xsl:text>
  432.                             </xsl:otherwise>
  433.                          </xsl:choose>
  434.                     </xsl:attribute>
  435.  
  436.                     <!-- get the embedded content -->
  437.                     <xsl:apply-templates>
  438.                         <xsl:with-param name="globalData" select="$globalData" />
  439.                     </xsl:apply-templates>
  440.                 </xsl:element>
  441.             </xsl:when>
  442.  
  443.             <xsl:when test="contains($styleProperties, 'size')">
  444.                 <xsl:element namespace="{$namespace}" name="font">
  445.                     <xsl:attribute name="size">
  446.                         <xsl:value-of select="substring-after(substring-before($styleProperties ,':size'), 'size:')" />
  447.                     </xsl:attribute>
  448.  
  449.                     <!-- get the embedded content -->
  450.                     <xsl:apply-templates>
  451.                         <xsl:with-param name="globalData" select="$globalData" />
  452.                     </xsl:apply-templates>
  453.                 </xsl:element>
  454.             </xsl:when>
  455.  
  456.             <xsl:otherwise>
  457.                 <!-- get the embedded content -->
  458.                 <xsl:apply-templates>
  459.                     <xsl:with-param name="globalData" select="$globalData" />
  460.                 </xsl:apply-templates>
  461.             </xsl:otherwise>
  462.         </xsl:choose>
  463.     </xsl:template>
  464.  
  465. </xsl:stylesheet>
  466.